﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Saker.Kernel.BLL;

namespace Saker.Web.Boss.Sys.Modules
{
    public partial class AuthorityPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }
        public void BindData()
        {
            int recordcount = 0, pagecount = 0;
            DataTable dt = new SysAuthorityDirBLL().GetPagingRecord(AuthorityPager.CurrentPageIndex - 1, ref recordcount, AuthorityPager.PageSize, ref pagecount, "");
            AuthorityList.DataSource = dt;
            AuthorityList.DataBind();
            AuthorityPager.RecordCount = recordcount;
        }

        protected void AuthorityList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "DeleteAuthority")
            {
                if (new SysAuthorityDirBLL().DeleteByAuthorityID(int.Parse(e.CommandArgument.ToString())) > 0)
                {
                    BindData();
                    ScriptManager.RegisterStartupScript((Page)this, this.Page.GetType(), "alert", "$(function () { top.jBox.tip('用户删除成功！', 'success'); });", true);
                }
            }
        }
    }
}